package com.fqgj.xjd.user.dao.impl;

import com.fqgj.common.api.Page;
import com.fqgj.common.base.AbstractBaseMapper;
import com.fqgj.xjd.user.dao.UserKycDocumentDao;
import com.fqgj.xjd.user.entity.UserKycDocumentEntity;
import com.fqgj.xjd.user.entity.business.UserKycStatisticsEntity;
import org.springframework.stereotype.Repository;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * User: zsp
 * Date: 2018-10-24
 * Time: 16:29:20.763
 */
@Repository
public class UserKycDocumentDaoImpl extends AbstractBaseMapper<UserKycDocumentEntity> implements UserKycDocumentDao {

    /**
     * 获取没有经过人脸识别的用户kyc列表
     */
    @Override
    public List<UserKycDocumentEntity> selectNoFaceRecognitionKycList(Integer limitSearch) {
        Map<String, Object> map = new HashMap<>();
        map.put("limitSearch", limitSearch);
        return getSqlSession().selectList(getStatement("selectNoFaceRecognitionKycList"), map);
    }

    @Override
    public UserKycDocumentEntity selectByUserCode(String userCode) {
        Map<String, Object> map = new HashMap<>();
        map.put("userCode", userCode);
        return getSqlSession().selectOne(getStatement("selectByUserCode"), map);
    }

    /**
     * 获取没有经过人脸识别的用户kyc列表
     */
    @Override
    public List<UserKycDocumentEntity> selectNoScanSelfieList(Integer limitSearch) {
        Map<String, Object> map = new HashMap<>();
        map.put("limitSearch", limitSearch);
        return getSqlSession().selectList(getStatement("selectNoScanSelfieList"), map);
    }

    /**
     * kyc 调用量统计
     *
     * @param authType
     * @param startDate
     * @param endDate
     * @return
     */
    @Override
    public List<UserKycStatisticsEntity> selectUserKycStatistics(String authType, Date startDate, Date endDate) {
        Map<String, Object> map = new HashMap<>();
        map.put("startDate", startDate);
        map.put("endDate", endDate);
        map.put("authType", authType);
        return getSqlSession().selectList(getStatement("selectUserKycStatistics"), map);
    }


    @Override
    public List<UserKycDocumentEntity> selectListByPage(Page page, Date date) {
        Map<String, Object> map = new HashMap<>();
        map.put("page", page);
        map.put("endDate", date);
        return getSqlSession().selectList(getStatement("selectListByPage"), map);
    }

    @Override
    public int updateUserKycDocumentEntity(String userCode, Integer authType, Integer status, String cardFrontUrl, String cardBackUrl, String handHoldUrl) {
        Map<String, Object> map = new HashMap<>();
        map.put("userCode", userCode);
        map.put("authType", authType);
        map.put("status", status);
        map.put("cardFrontUrl", cardFrontUrl);
        map.put("cardBackUrl", cardBackUrl);
        map.put("handHoldUrl", handHoldUrl);
        return getSqlSession().update(getStatement("updateUserKycDocumentEntity"), map);
    }
}